﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.BillingInformations
{
    public class BillingInformationCompanyNameSpecification: Specification<BillingInformation>
    {

        private string _companyName;

        public BillingInformationCompanyNameSpecification(string corporateName)
        {
            this._companyName = corporateName;
        }


        public override System.Linq.Expressions.Expression<Func<BillingInformation, bool>> SatisfiedBy()
        {
            Specification<BillingInformation> spec = new TrueSpecification<BillingInformation>();

            spec &= new DirectSpecification<BillingInformation>(c => !string.IsNullOrEmpty(this._companyName) 
                && c.CompanyName.Contains(this._companyName));

            return spec.SatisfiedBy();

        }
    }
}
